#ifndef MIDDLEWARE_H
#define MIDDLEWARE_H

#include <memory>

#include "../http/HttpRequest.h"
#include "../http/HttpResponse.h"

class Middleware
{
public:
    virtual ~Middleware() = default;

    virtual void before(HttpRequest &request) = 0;  // 请求前处理；可能需要修改所以&
    virtual void after(HttpResponse &response) = 0; // 响应后处理

    // 设置下一个中间件
    void setNext(std::shared_ptr<Middleware> nextMiddleware)
    {
        this->nextMiddleware_ = nextMiddleware;
    }

protected:
    std::shared_ptr<Middleware> nextMiddleware_;
};

#endif